<{include file="public/header" title='$edata.title' description='$edata.description'/}>

<style>
  html, body {width: 100%;height: 100%; margin: 0px;  padding: 0px; background-color: ;}
  .title{text-align: center;font-size: 15px;line-height: 40px;}
  .answerborder{border: #ccc 2px solid;border-radius:5px;padding: 2px 5px 0px 5px;}
  hr {height: 1px;/* margin: 10px 0; */ border: 0;clear: both;}
  .layui-col-md6{margin:0;border-bottom: #ccc 1px solid; padding: 3px;margin-bottom: -1px;}
  .clock{width: 100%;height: 30px;background-color: #FAEBD7;position:fixed;top:0px;left:0px;z-index:999;}
img{height: auto; max-width: 100%;}
.layui-form-item{margin-bottom:5px;clear:both;*zoom:1;}
.layui-form-item .layui-input-inline{float:left;width:20px;margin-right:10px;margin:2px 10px;}
/*img{max-width: 300px; height:auto; width:expression(this.width > 300 ? "300px" : this.width);*/

</style>
<div class="clock" style="text-align: center;"><i class="layui-icon layui-icon-time" style="font-size: 20px; color: #FF5722;line-height: 30px;"><span id="showtime" style="font-size: 15px; margin-left: 5px;line-height: 30px;" > </span></i>  </div>
<body style="padding-top: 25px;">

  <div class="layui-container" >
  	<div class="layui-row">&nbsp;</div>
	<div class="layui-row title" >
		<b><{$edata.title}></b>
		
	</div>
	<div class="layui-row title" >
		<{$edata.description}>
	</div>
	<form class="layui-form" >
	<{volist name="qdata" id="vo"}>
		<div class="layui-row" style="padding: 5px 0;">
      <div class="layui-col-md12" >
        <b><{$vo.sort > floor($vo.sort) ? '' : $vo.sort.'、'}><{$vo.qtitle}></b>
      </div>
		</div>
		<{switch name="vo.qtype"}>
		    <{case value="1"}>
		    	<div class="layui-row answerborder" >
		    	<{volist name="vo.getanswers" id="vi"}>
			    	<div class="layui-col-md6 ">
              <div class="layui-form-item">
                <div class="layui-input-inline">
			    	      <input type="radio" name="answer[<{$vo.qid}>]" value="<{$vi.aid}>" title="">
                </div>
                <div style="vertical-align:middle;padding-top: 10px;"><{$vi.answercontent}></div>
              </div>
			    	</div>
		    	<{/volist}>
		    	</div>
		    <{/case}>
		    <{case value="2"}>
		    	<div class="layui-row answerborder" >
		    	<{volist name="vo.getanswers" id="vi"}>
			    	<div class="layui-col-md6 ">
              <div class="layui-form-item">
              <div class="layui-input-inline">
			    	    <input type="checkbox" name="answer[<{$vo.qid}>][]" value="<{$vi.aid}>" title="" lay-skin="primary">
                </div>  
                <div style="vertical-align:middle;padding-top: 10px;"><{$vi.answercontent}></div>
			    	  
              </div>
			    	</div>
		    	<{/volist}>
		    	</div>
		    <{/case}>
        <{case value="3"}>
          <div class="layui-row " >
            <div class="layui-col-md12">
            <div class="layui-form-item">
                <textarea id="tk<{$vo.qid}>" name="answer[<{$vo.qid}>]" placeholder="此处回答"  lay-verify="tiankong<{$vo.qid}>" class="layui-textarea" ></textarea>
                <script>
                layui.use(['form','jquery','layedit'], function(){
                    var $ = layui.$,layedit = layui.layedit,form=layui.form,tkid='tk'+'<{$vo.qid}>';
                    layedit.set({
                      uploadImage: {
                        url: "<{:url('admin/upload/upimg')}>" //接口url
                        ,type: '' //默认post
                      }
                    });
                    var edittk=layedit.build(tkid,{
                      tool: ['image'],height:60
                    });
                    form.verify({ 
                      tiankong<{$vo.qid}>: function(value) { return layedit.sync(edittk);}
                    });
                    //alert(bb);
                    //console.log(form.verify);
                  })</script>
              </div >
              </div>
          </div>
        <{/case}>
		    <{default /}>
		    	
		<{/switch}>
		
	   
	
  	<{/volist}>
  	
  	<input type="hidden" name="eid" id="type" value="<{$edata.eid}>">
  	<div class="layui-row" style="margin-top: 30px;">
    	<button class="layui-btn layui-btn-fluid" lay-submit id="select" lay-filter="answersub" type = "button">立即提交</button>
  	</div>
  		
  	</form>
  </div>
   
  








	<div style="height: 50px;"></div>
  <div class="layui-footer" style="text-align: center;">
            <!-- 底部固定区域 -->
            &copy; 2020 |&nbsp;<img src="" alt=""> <{$Think.config.app_name}> | <{$Think.config.site_name}> | Design by <a href="javascript:;" id="me"> hxb0810</a>

  </div>







  
 




<script>
//JavaScript代码区域
layui.use(['element','jquery','layer','form'], function(){
  var element = layui.element,$ = layui.$,layer=layui.layer,form=layui.form;
  form.on('submit(answersub)', function(data){
      //console.log(data.field);

    // layer.alert(JSON.stringify(data.field), {
    //   title: '最终的提交信息'
    // });
    
    //alert(layedit.getContent(editquestion));
        layer.confirm('确定交卷?', {btn: ['提交','取消'],btnAlign: 'c', title:'请确认'}
        ,function(index){
          //do something
            $.post("<{:url('do_answer')}>",data.field,function(data,status){
              //alert(data);
              //layer.alert(JSON.stringify(data));
              //console.log(data);
              if(data===1){
                layer.close(index);
                layer.alert('提交成功!',function(){
                  //window.location.reload()
                  window.history.back(-1); 
                }); 
              }else{
                  layer.alert(data);
              }
                
              
           })
          
        });  
   });
    var showtime = function () {
        var nowtime = new Date(),  //获取当前时间
            //endtime = new Date("2020/8/8");  //定义结束时间
            endtime = new Date("<{$endtime|date='Y/m/d H:i:s',###}>");
        var lefttime = endtime.getTime() - nowtime.getTime(),  //距离结束时间的毫秒数
            leftd = Math.floor(lefttime/(1000*60*60*24)),  //计算天数
            lefth = Math.floor(lefttime/(1000*60*60)%24),  //计算小时数
            leftm = Math.floor(lefttime/(1000*60)%60),  //计算分钟数
            lefts = Math.floor(lefttime/1000%60);  //计算秒数
        //return leftd + "天" + lefth + ":" + leftm + ":" + lefts;  //返回倒计时的字符串
        if (leftd >= 1 ) {
          return leftd + "天" + lefth + ":" + leftm + ":" + lefts;
        } else {
          return  lefth + ":" + leftm + ":" + lefts;
        }
        
    };
    var div = document.getElementById("showtime");
    setInterval (function () {
        div.innerHTML = showtime();
    }, 1000);  //反复执行函数本身
    //定时弹窗

   $(document).ready(function(){
    var thistime = new Date(),overtime = new Date("<{$endtime|date='Y/m/d H:i:s',###}>");
        //setTimeout(function(){ layer.alert('离考试结束时间还有5分钟！'); },overtime.getTime()-thistime.getTime()-300000);
        setTimeout(function(){ $('#select').click(); },overtime.getTime()-thistime.getTime());
    })

});
</script>
</body>
</html>